package src.com.doit.demo01;

import java.util.ArrayList;
import java.util.Collection;

//增强for循环
//底层是个叠加器,所以使用的时候,不能修改长度
public class test_foreach {
    public static void main(String[] args) {
        int [] arr = {3,8,2,5,0};

        for (int a:arr)
        {
            System.out.println(a);
        }

        Collection<Person> c = new ArrayList<>();
        c.add(new Person(12,"柳岩"));
        c.add(new Person(18,"唐嫣"));
        for (Person p : c)
        {
            System.out.println(p.getName()+" "+p.getAge());
        }
        for (Person p : c)
        {
            System.out.println(p.getName()+" "+p.getAge());
        }
    }
}
